var l=Object.defineProperty;var i=(r,e,t)=>e in r?l(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var a=(r,e,t)=>(i(r,typeof e!="symbol"?e+"":e,t),t);import{elementIsExistWithLog as n}from"../generalFunctions.js";export default class o{constructor(e,...t){a(this,"parallaxContainer");a(this,"containerRect");a(this,"containerCenterCoordX");a(this,"containerCenterCoordY");a(this,"minWorkWidth");a(this,"parallaxElements",new Array);n("Parallax",e.parallaxContainerSelector)&&(this.parallaxContainer=document.querySelector(e.parallaxContainerSelector),this.parallaxElements=t,this.containerRect=this.parallaxContainer.getBoundingClientRect(),this.containerCenterCoordX=Math.round(this.containerRect.width/2),this.containerCenterCoordY=Math.round(this.containerRect.height/2),this.minWorkWidth=e.minWorkWidth,window.matchMedia("(prefers-reduced-motion: reduce)").matches||this.parallaxContainer.addEventListener("pointermove",this.pointerMoveHandler.bind(this)))}pointerMoveHandler(e){window.outerWidth>=this.minWorkWidth&&this.moveElements(e)}moveElements(e){for(let t of this.parallaxElements)t.parallax(e.pageX-this.parallaxContainer.offsetLeft-this.containerCenterCoordX,e.pageY-this.parallaxContainer.offsetTop-this.containerCenterCoordY)}}export class ParallaxElement{constructor(e){a(this,"htmlElement");a(this,"parallaxCoeffX");a(this,"parallaxCoeffY");n("ParallaxElement",e.selector)&&(this.htmlElement=document.querySelector(e.selector),this.htmlElement.style.transition="translate 0.1s ease",this.parallaxCoeffX=e.parallaxCoefficients[0],this.parallaxCoeffY=e.parallaxCoefficients[1]??e.parallaxCoefficients[0])}async parallax(e,t){this.htmlElement.style.translate=`${Math.round(e*this.parallaxCoeffX)}px 
      ${Math.round(t*this.parallaxCoeffY)}px 
      0`}}
